﻿using System.Globalization;
using Avalonia.Data.Converters;
using KinonekoSoftware.CodariaDB.Documents.DataParts.Modules.RVE;
using KinonekoSoftware.CodariaDB.Languages;
using KinonekoSoftware.Studio.Models.Modules;

namespace KinonekoSoftware.Studio.Resources.Converters
{
    public class ModuleBlockNameConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            
            // TODO: step 3： add ModuleBlockType converter name
            if (value is ModuleBlockType tBlock)
            {
                return tBlock switch
                {
                    ModuleBlockType.Color       => CodariaSR.Module_Block_Color,
                    ModuleBlockType.Text        => CodariaSR.Module_Block_Text,
                    ModuleBlockType.Switch      => CodariaSR.Module_Block_Switch,
                    ModuleBlockType.Paragraph   => CodariaSR.Module_Block_Paragraph,
                    ModuleBlockType.RVE         => CodariaSR.Module_RVE,
                    ModuleBlockType.LeadingText => CodariaSR.Module_Block_LeadingText,
                    ModuleBlockType.Degree => CodariaSR.Module_Block_Degree,

                    _ => CodariaSR.Module_Block_Numeric,
                };
            }

            if (value is RVEElementType tRve)
            {
                return tRve switch
                {
                    RVEElementType.Zodiac        => CodariaSR.Module_RVE_Zodiac,
                    RVEElementType.ChineseZodiac => CodariaSR.Module_RVE_ChineseZodiac,
                    RVEElementType.Text          => CodariaSR.Module_Element_Text,
                    RVEElementType.Numeric       => CodariaSR.Module_Element_Numeric,
                    RVEElementType.Option        => CodariaSR.Module_Element_Option,
                    _                            => CodariaSR.Module_RVE_Dashboard,
                };
            }

            // TODO: step 4： add ModuleElementType converter name
            if (value is ModuleElementType tElement)
            {
                return tElement switch
                {
                    ModuleElementType.Text    => CodariaSR.Module_Element_Text,
                    ModuleElementType.Numeric => CodariaSR.Module_Element_Numeric,
                    ModuleElementType.Degree => CodariaSR.Module_Element_Degree,
                    _                         => CodariaSR.Module_Element_Color,
                };
            }

            if (value is ModulePresenter presenter)
            {
                return presenter.GetTitle();
            }

            return CodariaSR.Module_RVE;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}